﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using IDAL;
using DAL;
using Models;

namespace BLL
{
    public class NewsCategoryInfoLogic
    {
        public static INewsCategoryInfo newscategory = new NewsCategoryInfoDAL();
        public static List<NewsCategoryInfo> GetAllNewsCategoryInfo()
        {
            return GetAllNewsCategoryInfo(0);
            
        }
        public static List<NewsCategoryInfo> GetAllNewsCategoryInfo(int CategoryID)
        {
            List<NewsCategoryInfo> list = new List<NewsCategoryInfo>();
            list = newscategory.GetAllNewsCategoryInfo();
            for (int i = 0; i < list.Count; i++)
            {
                if (list[i].CategoryID == CategoryID)
                {
                    list[i].NowPlace = "nowcf";
                    list[i].CurrentFlag = "current";
                }
                else
                {
                    list[i].NowPlace = "";
                    list[i].CurrentFlag = "";
                }
                if (list[i].HasNNews == 1)
                {
                    list[i].NewNews = "<div class='ncflag'></div>";
                }
                else
                {
                    list[i].NewNews = "";
                }
            }
            return list;
        }
        public static NewsCategoryInfo GetOneNewsCategoryInfo(int NewsID)
        {
            NewsCategoryInfo newscategoryinfo = newscategory.GetOneNewsCategoryInfo(NewsID);
            return newscategoryinfo;
        }
        public static int AddNewsCategoryInfo(NewsCategoryInfo newsCategoryInfo)
        {
            return newscategory.AddNewsCategoryInfo(newsCategoryInfo);
        }
        public static int DeleteNewsCategoryInfo(int CategoryID)
        {
            return newscategory.DeleteNewsCategoryInfo(CategoryID);
        }

        public static int UpdateNewsCategoryInfo(NewsCategoryInfo nc)
        {
            return newscategory.UpdateNewsCategoryInfo(nc);
        }
        public static int SetCategoryHasNews(int CategoryID)
        {
            return newscategory.UpdateCategoryHasNews(CategoryID, 1);
        }
        public static List<NewsCategoryInfo> GetAdminNewsCategoryInfo()
        {
            return newscategory.GetAdminNewsCategoryInfo();
        }
    }
}
